package com.src.myapplication.ui.view.fragmentpemgyou;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.google.gson.Gson;
import com.src.myapplication.R;
import com.src.myapplication.base.BaseFragmentSwp;
import com.src.myapplication.bean.FuJingDeRenben;
import com.src.myapplication.config.UrlConfig;
import com.src.myapplication.widget.CommonAdapter;
import com.src.myapplication.widget.base.ViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2016/10/17.
 */
public class FrgmentFuJing extends BaseFragmentSwp {

    private RecyclerView mRcv;
    @Override
    protected void initData(View view) {
        mRcv = (RecyclerView) view.findViewById(R.id.rcv);

    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_pengyou_fujin_;
    }

    @Override
    public int getid() {
        return R.id.sw;
    }

    @Override
    public String geturl() {
        return UrlConfig.PengYou.PENGYOU_FUJINDEREN;
    }


    @Override
    public Class<? extends Object> getben() {
        return FuJingDeRenben.class;
    }


    @Override
    public void addList(String string) {
        if (string != null) {
            Gson gson = new Gson();
            FuJingDeRenben paiHangBangben = gson.fromJson(string, FuJingDeRenben.class);
            List<FuJingDeRenben.ListBean> list1 = paiHangBangben.getList();
            CommonAdapter<FuJingDeRenben.ListBean> adapter = new CommonAdapter<FuJingDeRenben.ListBean>(getContext(), R.layout.fragment_fujinderen_list, list1) {
                @Override
                protected void convert(ViewHolder holder, FuJingDeRenben.ListBean paiHangBangben, int position) {

                    String nickname = paiHangBangben.getNickname();
                    String avatar = paiHangBangben.getAvatar();
                    String distance =paiHangBangben.getDistance();
                    String share = paiHangBangben.getLive().getHtml_share();
                    String rtmp = paiHangBangben.getLive().getRtmp();

                    SimpleDraweeView view = holder.getView(R.id.sdv);
                    TextView view1 = holder.getView(R.id.name);
                    TextView view2 = holder.getView(R.id.juli);

                    view.setImageURI(avatar);
                    view1.setText(nickname);
                    view2.setText(distance);
                }
            };
            LinearLayoutManager manager=new LinearLayoutManager(getContext());
            manager.setOrientation(LinearLayoutManager.VERTICAL);
            mRcv.setLayoutManager(manager);
            mRcv.setAdapter(adapter);
        }

    }


    @Override
    public void showLoadFailMsg() {

    }
}
